<?php
    //include_once 'init.php';
    if(!empty($_POST)){
        $username=$_POST['username'];//用户名
        $password=$_POST['password'];//密码
        $password1=$_POST['password1'];//确认密码
        $email=$_POST['email'];//邮箱
        $phone=$_POST['phone'];//手机
        $role_id=$_POST['role_id'];//手机
        $creat_time=time();//创建时间
        if($password!=$password1){
            echo '<script>alert("两次输入的密码不一致");history.go(-1);</script>';die;
        }
        $password=md5($password);
        $where['username']=$username;
        $where['password']=$password;
        $where['email']=$email;
        $where['phone']=$phone;
        $where['role_id']=$role_id;
        $where['creat_time']=$creat_time;
        $result=add($c,$where);
            if($result>0){
                include_once (LIB_PATH.'send_email.php');
                send_email();
                echo '<script>alert("管理员添加成功");location.href="index.php?c=admin&a=list&admin=1";</script>';die;
            }else{
                echo '<script>alert("管理员添加失败");history.go(-1);</script>';die;
            }
    }
    $data=getSelect('role','*');
    include(VIEW_PATH.$admin.'layout.html');
?>